﻿using System;
using System.Diagnostics.Tracing;
using System.Threading;

namespace Sustainalytics.Portfolios.BL
{
    [EventSource(Name = "Sustainalytics-ClientPlatform-PortfolioManagement")]
    public sealed class PortfolioSecuritiesManagementEventSource : EventSource
    {
        private static Lazy<PortfolioSecuritiesManagementEventSource> _lazyLog = new Lazy<PortfolioSecuritiesManagementEventSource>(InitLog, LazyThreadSafetyMode.ExecutionAndPublication);

        public static PortfolioSecuritiesManagementEventSource Log
        {
            get
            {
                return _lazyLog.Value;
            }
        }

        [NonEvent]
        public static PortfolioSecuritiesManagementEventSource InitLog()
        {
            var log = new PortfolioSecuritiesManagementEventSource();
            log.Ping();

            return log;
        }

        [Event(1, Level = EventLevel.LogAlways)]
        public void Ping()
        {
            if (IsEnabled())
                WriteEvent(1);
        }
    }
}
